//
//  BaseViewController.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/12.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "BaseViewController.h"
#import <MBProgressHUD.h>

@interface BaseViewController ()


@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self setMB];
    [self setNavi];
}

- (void)setNavi {
    self.modalTransitionStyle = 2;
    
    self.headerImgV = [UIImageView new];
    self.headerImgV.image = [UIImage imageNamed:@"diary-header"];
    self.headerImgV.userInteractionEnabled = YES;
    [self.view addSubview:self.headerImgV];
    [self.headerImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.top.equalTo(@20);
        make.height.equalTo(@(kScreenHeight / 12));
    }];
    
    self.titleLab = [UILabel new];
    self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.headerImgV addSubview:self.titleLab];
    [self.headerImgV addSubview:self.backBtn];
    [self.headerImgV addSubview:self.editBtn];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.headerImgV.mas_centerX);
        make.width.equalTo(@(kScreenWidth * 0.6));
        make.top.equalTo(@((kScreenHeight / 12) * 0.25));
        make.height.equalTo(@((kScreenHeight / 12) * 0.4));
    }];
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.width.equalTo(@(kScreenWidth * .15));
        make.height.equalTo(@25);
        make.centerY.mas_equalTo(self.titleLab.mas_centerY);
    }];
    [self.editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.width.equalTo(@(kScreenWidth * .15));
        make.height.equalTo(@25);
        make.centerY.mas_equalTo(self.titleLab.mas_centerY);
    }];
    
    self.titleLab.textColor = [UIColor whiteColor];
    self.titleLab.font = [UIFont systemFontOfSize:20];
    self.titleLab.textAlignment = NSTextAlignmentCenter;
    [self.backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [self.backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.backBtn setBackgroundImage:[UIImage imageNamed:@"go-back"] forState:UIControlStateNormal];
    [self.backBtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.editBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.editBtn setBackgroundImage:[UIImage imageNamed:@"right-button"] forState:UIControlStateNormal];
}

- (void)setMB {
    MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];
    [HUD show:YES];
}

- (void)backBtnClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
